home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Tools / ckmail / ckmail.c next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  16.2 KB  |  772 lines

  1. /* ckmail.c: tool to allow user to query status of users msgs */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Tools/ckmail/RCS/ckmail.c,v 6.0 1991/12/18 20:29:15 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Tools/ckmail/RCS/ckmail.c,v 6.0 1991/12/18 20:29:15 jpo Rel $
  9.  *
  10.  * $Log: ckmail.c,v $
  11.  * Revision 6.0  1991/12/18  20:29:15  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include "Qmgr-ops.h"           /* operation definitions */
  20. #include "Qmgr-types.h"         /* type definitions */
  21. #include "retcode.h"
  22. #include <isode/cmd_srch.h>
  23. #include "adr.h"
  24. #include "alias.h"
  25. #include "ap.h"
  26. #include "or.h"
  27. #include <pwd.h>
  28. #include "ryinitiator.h"        /* for generic interactive initiators */
  29.  
  30. /*   */
  31. extern CMD_TABLE
  32.     atbl_ctrl_addrs[/* Env-crl-address */];
  33. extern char    *loc_dom_site, *pplogin, *postmaster;
  34. extern UTC    utclocalise();
  35. /* DATA */
  36. static char *myservice =     "pp qmgr";
  37.  
  38. /* OPERATIONS */
  39. static int     do_readmsginfo(),
  40.         do_quit(),
  41.         p_msg(),
  42.         p_msginfo(),
  43.         p_recip(),
  44.         isPP();
  45.      
  46.  
  47. /* RESULTS */
  48. int     readmsginfo_result();
  49.     
  50. /* ERRORS */
  51. int     general_error ();
  52.  
  53. #define readmsginfo_error     general_error
  54.  
  55. static struct client_dispatch dispatches[] = {
  56. {
  57.     "readmsginfo", operation_Qmgr_readmsginfo,
  58.     do_readmsginfo,
  59. #ifdef PEPSY_VERSION
  60.     &_ZQmgr_mod, _ZReadMessageArgumentQmgr,
  61. #else
  62.     free_Qmgr_readmsginfo_argument,
  63. #endif
  64.     readmsginfo_result, readmsginfo_error,
  65.     "Read set of messages"
  66. },
  67. {
  68.     "quit",     0,      do_quit,
  69. #ifdef    PEPSY_VERSION
  70.     NULL, 0,
  71. #else
  72.     NULLIFP, 
  73. #endif
  74.     NULLIFP, NULLIFP,
  75.     "terminate the association and exit",
  76. },
  77. {
  78.     NULL
  79. }
  80. };
  81.  
  82. char    *qhost;        /* host to query */
  83. int    first;
  84. int    all = FALSE;
  85. int     verbose = FALSE;
  86. int    time_out, first, do_loop = FALSE;
  87. int    haveUid, userId;
  88. int debug = 0;
  89. char    *userAlias;
  90. ADDR    *ad;
  91. char    *name;
  92. extern char    *qmgr_hostname;
  93. #define MAX_NUM_IGNORES    30
  94. static char    *ignores[MAX_NUM_IGNORES];
  95. static int    numIgnores;
  96.  
  97. /*   */
  98. main(argc, argv)
  99. int    argc;
  100. char    **argv;
  101. {    
  102.     char    *myname;
  103.     int    opt;
  104.     extern char    *optarg;
  105.     extern int    optind;
  106.     if (myname = rindex (argv[0], '/'))
  107.         myname++;
  108.     if (myname == NULL || *myname == NULL)
  109.         myname = argv[0];
  110.  
  111.     sys_init(myname);
  112.     or_myinit();
  113.     
  114.     qhost = strdup(qmgr_hostname);
  115.     all = FALSE;
  116.     numIgnores = 0;
  117.     ignores[numIgnores++] = "msg-clean";
  118.     verbose = FALSE;
  119.     do_loop = FALSE;
  120.     first = 0;
  121.     haveUid = NOTOK;
  122.     userAlias = NULLCP;
  123.     while ((opt = getopt(argc, argv, "dvVaAh:H:l:L:u:U:i:I:c:C:")) != EOF) {
  124.         switch (opt) {
  125.             case 'a':
  126.             case 'A':
  127.             all = TRUE;
  128.             break;
  129.             case 'd':
  130.             debug = 1;
  131.             break;
  132.             case 'v':
  133.             case 'V':
  134.             verbose = TRUE;
  135.             break;
  136.             case 'h':
  137.             case 'H':
  138.             if (optarg[0] == '-') {
  139.                 printf("Illegal host '%s' (starts with a '-')\n",
  140.                        optarg);
  141.                 exit(0);
  142.             }
  143.             qhost = optarg;
  144.             break;
  145.             case 'l':
  146.             case 'L':
  147.             if (optarg[0] =='-') {
  148.                 printf ("Expecting time in minutes got '%s'", optarg);
  149.                 exit(0);
  150.             }
  151.             time_out = atoi(optarg);
  152.             do_loop = TRUE;
  153.             break;
  154.  
  155.             case 'u':
  156.             case 'U':
  157.             if (isPP() == NOTOK) {
  158.                 printf("You are not a mail superuser and so cannot use the '-u' flag\n");
  159.                 exit(0);
  160.             }
  161.             userAlias = optarg;
  162.             break;
  163.  
  164.             case 'i':
  165.             case 'I':
  166.             if (isPP() == NOTOK) {
  167.                 printf("You are not a mail superuser and so cannot use the '-i' flag\n");
  168.                 exit(0);
  169.             }
  170.             userId = atoi(optarg);
  171.             haveUid = OK;
  172.             break; 
  173.             
  174.             case 'c':
  175.             case 'C':
  176.             if (numIgnores >= MAX_NUM_IGNORES) {
  177.                 printf("can only ignore %d channels\n", MAX_NUM_IGNORES);
  178.                 exit (0);
  179.             }
  180.             ignores[numIgnores++] = optarg;
  181.             break;
  182.             default:
  183.             printf("usage: %s [-v] [-a] [-c channel] [-h host] [-l time] [-u user] [-i uid]\n",argv[0]);
  184.             exit(0);
  185.         }
  186.     }
  187.     fillinaddr();
  188.     if (verbose == TRUE) {
  189.         printf("Please wait while attempt to connect to %s....",qhost);
  190.         fflush(stdout);
  191.     }
  192.     if (do_loop == TRUE) {
  193.         while (TRUE) {
  194.             (void) ryinitiator (myname, qhost,
  195.                         argc, argv, myservice,
  196.                         table_Qmgr_Operations,
  197.                         dispatches, do_quit);
  198.             first++;
  199.             sleep (time_out*60);
  200.         }
  201.     } else
  202.         (void) ryinitiator (myname, qhost,
  203.                     argc, argv, myservice,
  204.                     table_Qmgr_Operations,
  205.                     dispatches, do_quit);
  206.  
  207.     exit(0);    
  208. }
  209.  
  210. /*   */
  211. /* OPERATIONS */
  212.  
  213. /* ARGSUSED */
  214. static int  do_quit (sd, ds, args, arg)
  215. int     sd;
  216. struct client_dispatch *ds;
  217. char  **args;
  218. char **arg;
  219. {
  220.     struct AcSAPrelease acrs;
  221.     register struct AcSAPrelease   *acr = &acrs;
  222.     struct AcSAPindication  acis;
  223.     register struct AcSAPindication *aci = &acis;
  224.     register struct AcSAPabort *aca = &aci -> aci_abort;
  225.  
  226.     if (AcRelRequest (sd, ACF_NORMAL, NULLPEP, 0, NOTOK, acr, aci) == NOTOK)
  227.         acs_adios (aca, "A-RELEASE.REQUEST");
  228.  
  229.     if (!acr -> acr_affirmative) {
  230.         (void) AcUAbortRequest (sd, NULLPEP, 0, aci);
  231.         adios (NULLCP, "Release rejected by peer: %d", acr -> acr_reason);
  232.     }
  233.  
  234.     ACRFREE (acr);
  235.  
  236. /*    exit (0);*/
  237.  
  238. }
  239.  
  240. static struct type_Qmgr_Filter        *fillin_1_to(name)
  241. char    *name;
  242. {
  243.     struct type_Qmgr_Filter    *ret = (struct type_Qmgr_Filter *)
  244.         calloc(1, sizeof(*ret));
  245.     ret->recipient = str2qb(name, strlen(name), 1);
  246.     return ret;
  247. }
  248.  
  249. static struct type_Qmgr_Filter        *fillin_1_from(name)
  250. char    *name;
  251. {
  252.     struct type_Qmgr_Filter    *ret = (struct type_Qmgr_Filter *)
  253.         calloc(1, sizeof(*ret));
  254.     ret->originator = str2qb(name, strlen(name), 1);
  255.     return ret;
  256. }
  257.  
  258. static struct type_Qmgr_FilterList    *fillinfilters(args)
  259. char    **args;
  260. {
  261.     struct type_Qmgr_FilterList    *head = NULL,
  262.                     *tail = NULL,
  263.                     *ix;
  264.     
  265.     ix = (struct type_Qmgr_FilterList *) calloc(1, sizeof(*ix));
  266.     ix->Filter = fillin_1_from(ad->ad_r822adr);
  267.     if (head == NULL)
  268.         head = tail = ix;
  269.     else {
  270.         tail->next = ix;
  271.         tail = ix;
  272.     }
  273.  
  274.     ix = (struct type_Qmgr_FilterList *) calloc(1, sizeof(*ix));
  275.     ix->Filter = fillin_1_from(ad->ad_r400adr);
  276.     if (head == NULL)
  277.         head = tail = ix;
  278.     else {
  279.         tail->next = ix;
  280.         tail =ix;
  281.     }
  282.     if (all == FALSE) 
  283.         return head;
  284.         
  285.     ix = (struct type_Qmgr_FilterList *) calloc(1, sizeof(*ix));
  286.     ix->Filter = fillin_1_to(ad->ad_r822adr);
  287.     if (head == NULL)
  288.         head = tail = ix;
  289.     else {
  290.         tail->next = ix;
  291.         tail = ix;
  292.     }
  293.  
  294.     ix = (struct type_Qmgr_FilterList *) calloc(1, sizeof(*ix));
  295.     ix->Filter = fillin_1_to(ad->ad_r400adr);
  296.     if (head == NULL)
  297.         head = tail = ix;
  298.     else {
  299.         tail->next = ix;
  300.         tail =ix;
  301.     }
  302.     return head;
  303. }
  304.  
  305. /* ARGSUSED */
  306. static do_readmsginfo (sd, ds, args, arg)
  307. int                sd;
  308. struct client_dispatch        *ds;
  309. char                **args; /* contains various filters */
  310. struct type_Qmgr_ReadMessageArgument    **arg;
  311. {
  312.     char    *str;
  313.     UTC    utc;
  314.  
  315.     *arg = (struct type_Qmgr_ReadMessageArgument *) malloc(sizeof(**arg));
  316.     
  317.     /* fillin time */
  318.     utc = (UTC) malloc (sizeof(struct UTCtime));
  319.  
  320.     utc->ut_flags = UT_SEC;
  321.     utc->ut_sec = 0;
  322.     str = utct2str(utc);
  323.     (*arg)->interval = str2qb(str, strlen(str), 1);
  324.     (*arg)->filters = fillinfilters(args);
  325.     if (debug) print_filterlist ((*arg)->filters);
  326.     return OK;
  327. }
  328.  
  329. /*   */
  330. /* RESULTS */
  331.  
  332. static int    isIgnored(chan)
  333. char    *chan;
  334. {
  335.     int    ix;
  336.  
  337.     for (ix = 0;ix < numIgnores;ix++)
  338.         if (lexequ(ignores[ix], chan) == 0)
  339.             return 1;
  340.     return 0;
  341. }
  342.  
  343. static char    *getChan(recip)
  344. struct type_Qmgr_RecipientInfo    *recip;
  345. {
  346.     struct type_Qmgr_ChannelList    *ic;
  347.     int    ix;
  348.     char    *chan = NULLCP;
  349.     
  350.     if (!recip) return NULLCP;
  351.  
  352.     for (ix = 0, ic = recip->channelList;
  353.          ix < recip->channelsDone && ic != NULL; 
  354.          ix++, ic = ic -> next);
  355.  
  356.     if (ic && ic -> Channel) {
  357.         chan = qb2str(ic -> Channel);
  358.         if (isIgnored(chan)) {
  359.             free(chan);
  360.             chan = NULLCP;
  361.         }
  362.     }
  363.     return chan;
  364. }
  365.  
  366. static int    isSender(msg)
  367. struct type_Qmgr_MsgStruct    *msg;
  368. {
  369.     char    *orig = qb2str(msg->recipientlist->RecipientInfo->user);
  370.     int    retval = 1;
  371.     if (strcmp(orig, ad->ad_r822adr) != 0
  372.         && strcmp(orig, ad->ad_r400adr) != 0) 
  373.         /* to user */
  374.         retval = 0;
  375.     free(orig);
  376.     return retval;
  377. }
  378.  
  379. static int isPrintable(msg, sender)
  380. struct type_Qmgr_MsgStruct    *msg;
  381. int                sender;
  382. {
  383.     char    *chan = NULLCP;
  384.     struct type_Qmgr_RecipientList    *ix;
  385.  
  386.     if (!sender)
  387.         return 1;
  388.     /* go through recip and see if getChan */
  389.     ix = msg->recipientlist;
  390.     ix = ix -> next; /* skip past sender */
  391.     while (ix != NULL && chan == NULLCP) {
  392.         chan = getChan(ix -> RecipientInfo);
  393.         ix = ix -> next;
  394.     }
  395.     if (chan == NULLCP)
  396.         return 0;
  397.     free(chan);
  398.     return 1;
  399. }
  400.     
  401. static int isPrintableMsg(msgs)
  402. struct type_Qmgr_MsgStructList *msgs;
  403. {
  404.     struct type_Qmgr_MsgStructList *ix = msgs;
  405.     int    printable = 0;
  406.     
  407.     while (ix != NULL && printable == 0) {
  408.         printable = isPrintable(ix -> MsgStruct, 
  409.                     isSender(ix->MsgStruct));
  410.         ix = ix -> next;
  411.     }
  412.     return printable;
  413. }
  414.         
  415.     
  416. /* ARGSUSED */
  417. int readmsginfo_result (sd, id, dummy, result, roi)
  418. int                        sd,
  419.                         id,
  420.                         dummy;
  421. register struct type_Qmgr_MsgList        *result;
  422. struct RoSAPindication                *roi;
  423. {
  424.     struct type_Qmgr_MsgStructList    *ix;
  425.     if (result == NULL || result->msgs == NULL
  426.         || !isPrintableMsg(result->msgs)) {
  427.         if (do_loop == FALSE || first == 0)
  428.             printf("There are no messages %s %s at %s\n",
  429.                    (all == TRUE) ? "to or from" : "from",
  430.                    name, qhost);
  431.     } else {
  432.         printf("The messages %s %s on %s are as follows:\n",
  433.                (all == TRUE) ? "to or from" : "from",
  434.                name, qhost);
  435.         ix = result->msgs;
  436.         while (ix != NULL) {
  437.             p_msg(ix->MsgStruct, isSender(ix->MsgStruct));
  438.             ix = ix->next;
  439.         }
  440.     }
  441.     return OK;
  442. }
  443.  
  444. static    int    p_msg(msg, sender)
  445. struct type_Qmgr_MsgStruct    *msg;
  446. {
  447.     int    len, tlen;
  448.     struct type_Qmgr_RecipientList    *ix;
  449.  
  450.     first = 1;
  451.     
  452.     if (!sender) {
  453.         /* to user */
  454.         if ((len = p_msginfo(msg->messageinfo, sender)) == 0)
  455.             return;
  456.         printf(" is from");
  457.         tlen = len + strlen(" is from") + 1;
  458.         p_recip(msg->recipientlist->RecipientInfo, tlen, 1);
  459.         if (verbose) {
  460.             printf ("\n%*s is pending delivery to", len, "");
  461.             first = 1;
  462.             for (ix = msg->recipientlist -> next;
  463.                  ix;  ix = ix -> next)
  464.                 p_recip (ix -> RecipientInfo, len, 0);
  465.         }
  466.         printf("\n");
  467.  
  468.     } else if (isPrintable(msg, sender)) {
  469.         ix = msg->recipientlist;
  470.         if ((len = p_msginfo(msg->messageinfo, sender)) == 0)
  471.             return;
  472.         if (verbose) {
  473.             printf (" is from");
  474.             p_recip (ix -> RecipientInfo, len, 1);
  475.             printf ("\n%*s", len, "");
  476.             first = 1;
  477.         }
  478.         ix = ix -> next;
  479.         if (ix != NULL) {
  480.             printf(" is pending delivery to");
  481.             len += strlen(" is pending delivery to") +1;
  482.             while (ix != NULL) {
  483.                 p_recip(ix->RecipientInfo, len, 0);
  484.                 ix = ix -> next;
  485.             }
  486.         } else
  487.             printf(" is waiting for notification/deletion");
  488.         printf("\n");
  489.     } 
  490. }
  491.  
  492. static int    p_msginfo(info, sender)
  493. struct type_Qmgr_PerMessageInfo    *info;
  494. int                sender;
  495. {
  496.     char    *id, buf[BUFSIZ];
  497.     int    retval;
  498.     UTC    ut, lut;
  499.     
  500.     id = qb2str(info->queueid);
  501.     retval = strlen(id);
  502.     printf("%s",id);
  503.     free(id);
  504.     if (info -> uaContentId != NULL) {
  505.         id = qb2str (info -> uaContentId);
  506.         printf (" with content id '%s'\n%*s", id, retval, " ");
  507.         free(id);
  508.     }
  509.     if (info -> age != NULL) {
  510.         id = qb2str(info -> age);
  511.         ut = str2utct(id, strlen(id));
  512.         lut = utclocalise (ut);
  513.         if (UTC2rfc (lut, buf) != NOTOK) 
  514.             printf (" submitted at %s\n%*s", buf, retval, " ");
  515.         if (lut) free ((char *) lut);
  516.         free(id);
  517.     }
  518.     if (verbose != TRUE)
  519.         return retval;
  520.     if (info -> expiryTime != NULL) {
  521.         id = qb2str (info -> expiryTime);
  522.         ut = str2utct(id, strlen(id));
  523.         lut = utclocalise(ut);
  524.         if (UTC2rfc (lut, buf) != NOTOK) 
  525.             printf (" will expire at %s\n%*s", buf, retval, " ");
  526.         if (lut) free ((char *) lut);
  527.         free(id);
  528.     }
  529.     if (info -> priority && info -> priority -> parm != 1)
  530.         printf (" priority %d\n%*s", info -> priority -> parm,
  531.             retval, "");
  532.     if (info -> size)
  533.         printf (" size %d\n%*s", info -> size, retval, "");
  534.     if (info -> numberWarningsSent)
  535.         printf (" %d warnings sent\n%*s", info -> numberWarningsSent,
  536.             retval, "");
  537.     if ((info -> optionals & opt_Qmgr_PerMessageInfo_errorCount) &&
  538.         info -> errorCount)
  539.         printf (" %d errors accumulated\n%*s", info -> errorCount,
  540.             retval, "");
  541.     
  542.     if (info -> deferredTime != NULL) {
  543.         id = qb2str (info -> deferredTime);
  544.         ut = str2utct(id, strlen(id));
  545.         lut = utclocalise(ut);
  546.         if (UTC2rfc (lut, buf) != NOTOK) 
  547.             printf (" deferred until %s\n%*s", buf, retval, " ");
  548.         if (lut) free ((char *) lut);
  549.         free(id);
  550.     }
  551.     
  552.     return retval;
  553. }
  554.  
  555. static int     p_recip(recip, tab, sender)
  556. struct type_Qmgr_RecipientInfo    *recip;
  557. int                tab;
  558. int                sender;
  559. {
  560.     char    *usr, *chan = NULLCP;
  561.  
  562.     if (!sender && (chan = getChan(recip)) == NULLCP)
  563.         return;
  564.  
  565.     if (first != 1)
  566.         printf(",\n%*s", tab, " ");
  567.     else
  568.         printf(" ");
  569.     first = 0;
  570.     
  571.     usr = qb2str(recip->user);
  572.     
  573.     if (sender  || chan == NULLCP)
  574.         printf("%s", usr);
  575.     else {
  576.         printf("%s (channel = %s)",usr, chan);
  577.         free(chan);
  578.     }
  579.     free(usr);
  580. }
  581.  
  582. /*   */
  583. /* ERRORS */
  584.  
  585. /* ARGSUSED */
  586. general_error (sd, id, error, parameter, roi)
  587. int     sd,
  588.     id,
  589.     error;
  590. caddr_t parameter;
  591. struct RoSAPindication *roi;
  592. {
  593.     register struct RyError *rye;
  594.  
  595.     if (error == RY_REJECT) {
  596.         advise (NULLCP, "%s", RoErrString ((int) parameter));
  597.         return OK;
  598.     }
  599.  
  600.     if (rye = finderrbyerr (table_Qmgr_Errors, error))
  601.         advise (NULLCP, "%s", rye -> rye_name);
  602.     else
  603.         advise (NULLCP, "Error %d", error);
  604.  
  605.     return OK;
  606. }
  607.  
  608. /*   */
  609. /* fillin an ADDR struct for person running this program */
  610.  
  611. fillinaddr()
  612. {
  613.     struct passwd *pwd;
  614.     RP_Buf    rp;
  615.  
  616.     if (userAlias != NULLCP) {
  617.         if ((pwd = getpwnam(userAlias)) == NULL)
  618.             name = userAlias;
  619.         else name = pwd -> pw_name;
  620.     } else if (haveUid == OK) {
  621.         if ((pwd = getpwuid(userId)) == NULL) 
  622.             adios (NULLCP,
  623.                    "Cannot get passwd entry for uid '%d'",
  624.                    userId);
  625.         name = pwd -> pw_name;
  626.     } else {
  627.         if ((pwd = getpwuid(getuid())) == NULL)
  628.             adios(NULLCP,"Cannot get your password entry");
  629.         name = pwd -> pw_name;
  630.     }
  631.     ad = adr_new(name, AD_ANY_TYPE, 0);
  632. #ifdef UKORDER
  633.     if (rp_isbad(ad_parse(ad, &rp, CH_UK_PREF))) 
  634. #else
  635.     if (rp_isbad(ad_parse(ad, &rp, CH_USA_PREF))) 
  636. #endif
  637.         adios(NULLCP, 
  638.               "Address parse failed\nReason : %s\n",rp.rp_line);
  639. }
  640.  
  641. static int isPP()
  642. {
  643.     RP_Buf    rp;
  644.     int    uid;
  645.     struct passwd    *tmp;
  646.     ADDR    *tmpadr;
  647.  
  648.     if ((uid = getuid()) == 0)
  649.         /* super user */
  650.         return OK;
  651.     if ((tmp = getpwuid(uid)) == NULL) {
  652.         printf("Cannot get your passwd entry\n");
  653.         exit(0);
  654.     }
  655.     tmpadr = adr_new(tmp->pw_name, AD_ANY_TYPE, 0);
  656.  
  657. #ifdef UKORDER
  658.     if (rp_isbad(ad_parse(tmpadr, &rp, CH_UK_PREF))) {
  659. #else
  660.     if (rp_isbad(ad_parse(tmpadr, &rp, CH_USA_PREF))) {
  661. #endif
  662.         printf("Cannot parse your mail address\nReason : %s\n",rp.rp_line);
  663.         exit(1);
  664.     }
  665.  
  666.     if ((strcmp(tmp->pw_name, pplogin) == 0)
  667.         || (strcmp(tmpadr->ad_r822adr, postmaster) == 0)) {
  668.         adr_free(tmpadr);
  669.         return OK;
  670.     }
  671.     adr_free(tmpadr);
  672.     return NOTOK;
  673. }
  674.  
  675. static int indent = 0;
  676.  
  677. static void print_qb (str, qb)
  678. char *str;
  679. struct qbuf *qb;
  680. {
  681.     struct qbuf *qp;
  682.  
  683.     printf ("%*s", indent * 2, "");
  684.     if (str)
  685.         printf ("%s: ", str);
  686.     for (qp = qb -> qb_forw; qp != qb; qp = qp -> qb_forw)
  687.         printf ("%*.*s", qp -> qb_len, qp -> qb_len,
  688.             qp -> qb_data);
  689.     putchar ('\n');
  690. }
  691.  
  692. static void print_eit (eit)
  693. struct type_Qmgr_EncodedInformationTypes *eit;
  694. {
  695.     printf("%*sEncodedInformationTypes\n", indent * 2, "");
  696.     indent ++;
  697.     while (eit) {
  698.         print_qb (NULLCP, eit -> PrintableString);
  699.         eit = eit -> next;
  700.     }
  701.     indent --;
  702. }
  703.  
  704. static void print_priority (prio)
  705. struct type_Qmgr_Priority *prio;
  706. {
  707.     printf ("%*sPriority: ", indent * 2, "");
  708.     switch (prio -> parm) {
  709.         case int_Qmgr_Priority_low:
  710.         printf ("low\n");
  711.         break;
  712.         case int_Qmgr_Priority_normal:
  713.         printf ("normal\n");
  714.         break;
  715.         case int_Qmgr_Priority_high:
  716.         printf ("high\n");
  717.         break;
  718.         default:
  719.         printf ("%d\n", prio -> parm);
  720.         break;
  721.     }
  722. }
  723.  
  724. static void print_mpdu (mpdu)
  725. struct type_Qmgr_MPDUIdentifier *mpdu;
  726. {
  727.     printf ("%*smpduiden\n", indent * 2, "");
  728. }
  729.  
  730. static void print_filter(f)
  731. struct type_Qmgr_Filter *f;
  732. {
  733.     printf ("%*sFilter\n", indent * 2, "");
  734.     indent ++;
  735.     if (f -> contenttype)
  736.         print_qb ("ContentType", f -> contenttype);
  737.     if (f -> eit)
  738.         print_eit (f->eit);
  739.     if (f -> priority)
  740.         print_priority (f->priority);
  741.     if (f -> moreRecentThan)
  742.         print_qb ("moreRecentThan", f -> moreRecentThan);
  743.     if (f -> earlierThan)
  744.         print_qb ("earlierThan", f -> earlierThan);
  745.     if (f -> maxSize)
  746.         printf ("%*smaxsize: %d\n", indent * 2, "", f -> maxSize);
  747.     if (f -> originator)
  748.         print_qb ("Originator", f -> originator);
  749.     if (f -> recipient)
  750.         print_qb ("Recipient", f -> recipient);
  751.     if (f -> channel)
  752.         print_qb ("Channel", f -> channel);
  753.     if (f -> mta)
  754.         print_qb ("Mta", f->mta);
  755.     if (f -> queueid)
  756.         print_qb ("Queueid", f -> queueid);
  757.     if (f -> mpduiden)
  758.         print_mpdu(f -> mpduiden);
  759.     if (f -> uaContentId)
  760.         print_qb ("UAContentId", f -> uaContentId);
  761.     indent --;
  762. }
  763.  
  764. print_filterlist (filterl)
  765. struct type_Qmgr_FilterList *filterl;
  766. {
  767.     while(filterl) {
  768.         print_filter (filterl -> Filter);
  769.         filterl = filterl -> next;
  770.     }
  771. }
  772.